<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>历史记录</title>
    <style>
        body {
            background: #f3f4f7;
            background-image: url("/static/assets/hisbk.jpg");
            background-repeat: no-repeat;
            background-size: cover;
        }
        .app {
            text-align: center;
            padding: 20px;
            height: 100%;
        }
        h1 {
            color: #eefced;
            text-shadow:2px 2px 2px#1e7118,2px 2px 2px#1e7118;
        }
        p {
            font-size: 1.2em;
            font-family: "仿宋", "SimHei", sans-serif;
            text-shadow:2px 2px 2px#1e7118,2px 2px 2px#1e7118;
            color:white;
        }
        .choice {
            background-color: none;
            width: 100%;
            position: relative;
            top: 30%;
            right: 2%;
            font-weight: bold;
            font-size: large;
            font-family: "宋体", "SimHei", sans-serif;
            color: rgb(14, 91, 14);
        }
        .choice ul {
            list-style-type: none;
        }
        .choice ul li {
            background-color: #f1f1f1;
            text-align: center;
            margin-bottom: 10px;
            padding-top: 10px;
            height: 30px;
            border-radius: 15px;
            width: 100px;
        }
        .choice ul li a {
            text-decoration: none;
            color: rgb(8, 90, 8);
            display: block;
            padding: 10px;
            text-align: center;
            border-radius: 15px;
            position: relative;
            bottom: 35%;

        }
        .choice ul li a:hover {
            background-color: rgb(49, 99, 27);
            color: white;
            box-shadow:3px 3px  2px #e0ffdeb9;
        }
        .container {
            display: flex;
            flex-direction: column;
        }
        .choice {
            display: flex;
            justify-content: space-around;
            list-style: none;
            padding: 0;
            margin: 0;
        }
        .horizontal-list {
            display: flex;
            align-items: center;
        }
        .horizontal-list li {
            margin: 0 10px;
        }
.chat-history {
            background-color: #eefced;
            border-radius: 15px;
            max-height: 400px; /* 设置最大高度 */
            overflow-y: auto; /* 垂直方向滚动 */
            padding: 15px;
            margin: 30px auto;
            width: 85%;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            border: 1px solid #c8e6c9;
        }
        .chat-history ul {
            list-style-type: none;
            color: rgb(8, 90, 8);
            padding: 0;
            margin: 0;
        }
        .chat-history ul li {
            background-color: #ffffff;
            text-align: left;
            margin-bottom: 15px;
            margin-left:10px;
            margin-right:10px;
            padding: 15px;
            border-radius: 10px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
            transition: all 0.3s ease;
            position: relative;
            border-left: 4px solid #4caf50;
        }
        .chat-history ul li:hover {
            transform: translateY(-3px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }
        .chat-history ul li:before {
            position: absolute;
            left: -25px;
            top: 15px;
            background: #4caf50;
            color: white;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            text-align: center;
            line-height: 20px;
            font-size: 12px;
        }
        .dog-img-l {
            width: 180px;
            max-width: 90%;   /* 小屏幕上自适应 */
            height: auto;
            display: block;   /* 消除图片底部间隙 */
            margin: 0 auto;   /* 居中显示 */
            /* border:red 5px solid; */
            position:absolute;
            top:5%;
            left:13%;
            z-index: 9999;
        }
        .dog-img-r {
            width: 205px;
            max-width: 90%;   /* 小屏幕上自适应 */
            height: auto;
            display: block;   /* 消除图片底部间隙 */
            margin: 0 auto;   /* 居中显示 */
            /* border:red 5px solid; */
            position:absolute;
            top:5%;
            right:12%;
            z-index: 9999;
        }

        .scroll-indicator {
            text-align: center;
            color: #4caf50;
            font-size: 0.9rem;
            margin-top: 10px;
            animation: bounce 2s infinite;
        }
        @keyframes bounce {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-5px); }
        }
        @media (max-width: 768px) {
            .dog-img-l, .dog-img-r {
                display: none;
            }
            .chat-history {
                width: 95%;
            }
            .horizontal-list {
                flex-direction: column;
                gap: 10px;
            }
        }
    </style>
</head>
<body>
    <div class="app">
        <h1>历史记录</h1>
        <p>by 食堂煎饼不好吃队</p>
        <img src="/static/assets/lsdog_l.png" alt="线条小狗左" class="dog-img-l">
        <img src="/static/assets/lsdog_r.png" alt="线条小狗右" class="dog-img-r">
        <div class="container">
            <div class="choice">
                <ul class="horizontal-list">
                    <li><a href="http://127.0.0.1:3001">主页</a></li>
                    <li><a href="http://127.0.0.1:5000">模拟对话</a></li>
                    <li><a href="http://127.0.0.1:3002">能力测试</a></li>
                    <li><a href="http://127.0.0.1:5001">历史记录</a></li>
                </ul>
            </div>
            <div class="chat-history">
                <ul id="chat-records">
                    <!-- Chat records will be inserted here -->
                     <!-- 示例聊天记录 -->

<!--                <div class="scroll-indicator">↑ 向上滚动查看历史记录 ↑</div>-->
                </ul>
            </div>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            console.log('Fetching chat history...');
            fetch('/chat_history')
                .then(response => {
                    console.log('Received response:', response);
                    return response.json();
                })
                .then(chatRecords => {
                    console.log('Chat records:', chatRecords);
                    const chatRecordsContainer = document.getElementById('chat-records');
                    chatRecords.forEach(record => {
                        const listItem = document.createElement('li');
                        listItem.textContent = `${record.question} - ${record.answer}`;
                        chatRecordsContainer.appendChild(listItem);
                    });
                })
                .catch(error => console.error('Error fetching chat history:', error));
        });
    </script>
</body>
</html>